package com.chen.subject.application.controller;

import com.alibaba.fastjson.JSON;
import com.chen.subject.common.entity.PageResult;
import com.chen.subject.infra.basic.entity.SubjectInfoEs;
import com.chen.subject.infra.basic.service.SubjectEsService;
import com.chen.subject.infra.entity.UserInfo;
import com.chen.subject.infra.rpc.UserRpc;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 测试fegin
 *
 */
@RestController
@RequestMapping("/subject/category")
@Slf4j
public class TestFeignController {

    @Resource
    private UserRpc userRpc;
    @Resource
    private SubjectEsService subjectEsService;
    @GetMapping("testFeign")
    public void testFeign() {
        UserInfo userInfo = userRpc.getUserInfo("jichi");
        log.info("testFeign.userInfo:{}", userInfo);
    }
    @PostMapping("test")
    public void test() {
        SubjectInfoEs subjectInfoEs = new SubjectInfoEs();
        subjectInfoEs.setKeyWord("mysql");
        PageResult<SubjectInfoEs> pageResult = subjectEsService.querySubjectList(subjectInfoEs);
        log.info("test:{}", JSON.toJSONString(pageResult));
        System.out.println(pageResult);
    }

}
